home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0793 / FASTCOPY.PAS < prev    next >
Pascal/Delphi Source File  |  1993-08-01  |  1KB  |  45 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 215 of 320                                                               
  3. From : Bart Vanhauwaert                    2:292/807.0          05 Jul 93  02:07 
  4. To   : JUSTIN TAWIL                                                              
  5. Subj : Help in quick moves                                                    
  6. ────────────────────────────────────────────────────────────────────────────────
  7. Hi Justin,  
  8.  
  9.  On 06-27-93 JUSTIN TAWIL wrote to ALL... 
  10.  
  11.  JT> Does anyone have an Inline source for moving bytes a word or a double 
  12.  JT> word at a time..I need to copy data in and out of buffer very 
  13.  JT> quickly..Thanks.. 
  14.  
  15. For a 8086,80186,80286.}
  16.  
  17.  
  18. asm 
  19.    mov cx , Count          { In words, in bytes if you use movsb } 
  20.    push ds 
  21.    les DI , P2 
  22.    lds SI , P1 
  23.    cld 
  24.    rep movsw               { for words, replace by : movsb for bytes } 
  25.    pop  ds 
  26. end; 
  27.  
  28. For a 80386,80486 & probably a Pentium 
  29.  
  30. asm 
  31.    mov cx , Count 
  32.    push ds 
  33.    les DI , P2 
  34.    lds SI , P1 
  35. @L1:
  36.    mov ax , es:[di]      { use al for bytes } 
  37.    mov [si] , ax         { use al for bytes } 
  38.    loop @L1 
  39.    pop ds 
  40. end 
  41.  
  42. Both solutions will run on all processors, but will be faster on the 
  43. dedicated CPU. Btw P1 and P2 are pointers to the buffers. 
  44. There is no range checking. And the buffers may not be at the same piece 
  45. of memory.